import { ItemRule } from "../..";

const defaultRule = ref<ItemRule[]>([
  {
    type: "required",
    label: "必填",
    message: "必填项",
    pattern: null,
    required: true,
  },
  {
    type: "date",
    label: "数字",
    message: "请输入日期",
    pattern: null,
    required: true,
  },
  {
    type: "number",
    label: "日期",
    message: "请输入数字",
    pattern: null,
    required: true,
  },
  {
    type: "email",
    label: "邮箱",
    message: "请输入邮箱",
    pattern: null,
    required: true,
  },
  {
    type: "phone",
    label: "手机号",
    message: "请输入手机号",
    pattern: /^0{0,1}(13[0-9]|15[7-9]|153|155|156|18[7-9])[0-9]{8}$/,
    required: true,
  },
  {
    type: "money",
    label: "金额",
    message: "请输入正确的金额，最多两位小数",
    pattern: /^[0-9]+\.?[0-9]{0,2}$/,
    required: true,
  },
  {
    type: "card",
    label: "身份证",
    message: "请输入身份证号",
    pattern:
      /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
    required: true,
  },
  {
    type: "int",
    label: "正整数",
    message: "请输入正整数",
    pattern: /^[0-9]*[1-9][0-9]*$/,
    required: true,
  },
  {
    type: "numberString",
    label: "数字字符串",
    message: "请输入数字",
    pattern: /^\d+(\.\d+)?$/,
    required: true,
  },
  {
    type: "url",
    label: "网址",
    message: "请输入网址",
    pattern: null,
    required: true,
  },
  {
    type: "regexp",
    label: "自定义正则",
    message: "必填项",
    pattern: null,
    required: true,
  },
]);

export default defaultRule;
